﻿/*
Copyright (c) 2008 William Duff

Permission is hereby granted, free of charge, to any person obtaining a copy 
of this software and associated documentation files (the "Software"), to deal 
in the Software without restriction, including without limitation the rights 
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace LiveUpload.Facebook
{
    /// <summary>
    /// Data related to a specific Facebook user.
    /// </summary>
    public class Account
    {
        #region Constructors

        /// <summary>
        /// Constructs a new Account object to represent a Facebook user.
        /// </summary>
        /// <param name="id">
        /// A unique identifier for the Facebook user.
        /// </param>
        /// <param name="session">
        /// Session information for the user.
        /// </param>
        public Account(string id, AccountSession session)
        {
            this.id = id;
            this.session = session;
        }

        #endregion

        #region Private Fields

        private string name;
        private string id;
        private string squarePictureUrl;
        private AccountSession session;
        private List<Album> albums;
        private List<Friend> friendList;
        private Permissions permissions;
        private string network;
        private VideoUploadLimits videoUploadLimits;

        #endregion

        #region Public Fields

        /// <summary>
        /// The name of the user.
        /// </summary>
        public string Name
        {
            get { return this.name; }
            set { this.name = value; }
        }

        /// <summary>
        /// A unique identifier for the user.
        /// </summary>
        public string Id
        {
            get { return this.id; }
            set { this.id = value; }
        }

        /// <summary>
        /// A URL of a square profile picture for the user.
        /// </summary>
        public string SquarePictureUrl
        {
            get { return this.squarePictureUrl; }
            set { this.squarePictureUrl = value; }
        }

        /// <summary>
        /// Session information for the user.
        /// </summary>
        public AccountSession Session
        {
            get { return this.session; }
            set { this.session = value; }
        }

        /// <summary>
        /// A list of albums created by the user.
        /// </summary>
        public List<Album> Albums
        {
            get { return this.albums; }
            set { this.albums = value; }
        }

        /// <summary>
        /// A list of friends for this user.
        /// </summary>
        public List<Friend> FriendList
        {
            get { return this.friendList; }
            set { this.friendList = value; }
        }

        /// <summary>
        /// A set of permissions specific to this user.
        /// </summary>
        public Permissions Permissions
        {
            get { return this.permissions; }
            set { this.permissions = value; }
        }

        /// <summary>
        /// The primary network the user is connected to.
        /// </summary>
        public string Network
        {
            get { return this.network; }
            set { this.network = value; }
        }

        public VideoUploadLimits VideoUploadLimits
        {
            get { return this.videoUploadLimits; }
            set { this.videoUploadLimits = value; }
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Generic equality function.
        /// </summary>
        /// <param name="obj">
        /// An object to compare equality with.
        /// </param>
        /// <returns>
        /// true if this is equal to the given object and false otherwise.
        /// </returns>
        public override bool Equals(object obj)
        {
            return this == obj as Account;
        }

        /// <summary>
        /// Checks for reference or value equality.
        /// </summary>
        /// <param name="left">
        /// The left hand side of the operator.
        /// </param>
        /// <param name="right">
        /// The right hand side of the operator.
        /// </param>
        /// <returns>
        /// true if the accounts are equal and false otherwise.
        /// </returns>
        public static bool operator ==(Account left, Account right)
        {
            if (object.ReferenceEquals(left, right))
            {
                return true;
            }
            else if (left is Account && right is Account)
            {
                return left.Id == right.Id;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Checks for reference or value inequality.
        /// </summary>
        /// <param name="left">
        /// The left hand side of the operator.
        /// </param>
        /// <param name="right">
        /// The right hand side of the operator.
        /// </param>
        /// <returns>
        /// true if the Accounts are not equal and false otherwise.
        /// </returns>
        public static bool operator !=(Account left, Account right)
        {
            return !(left == right);
        }

        /// <summary>
        /// Serves as a hash function for Account.
        /// </summary>
        /// <returns>
        /// A hash code.
        /// </returns>
        public override int GetHashCode()
        {
            return this.id.GetHashCode();
        }

        #endregion
    }
}
